import request from '@/utils/request'
import qs from 'qs'

export function findListByPage(params) {
  return request({
    url: 'api/sdm/convert/task' + '?' + qs.stringify(params, { indices: false }),
    method: 'get'
  })
}

export function add(data) {
  return request({
    url: 'api/sdm/convert/task',
    method: 'post',
    data
  })
}

export function edit(data) {
  return request({
    url: 'api/sdm/convert/task',
    method: 'put',
    data
  })
}

export function del(pkIds) {
  return request({
    url: 'api/sdm/convert/task' + pkIds,
    method: 'delete',
    data: pkIds
  })
}

export function upload(data) {
  return request({
    url: '/api/sdm/convert/task/upload',
    data: data,
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data;boundary=' + new Date().getTime()
    }
  })
}

export function downloadFile(fileType,taskPkId) {
  return request({
    url: `/api/sdm/convert/task/download/${fileType}/${taskPkId}`,
    method: 'get',
    responseType: 'blob'
  })
}

export function convertFile(fileType, taskPkId) {
  return request({
    url: `/api/sdm/convert/task/download/${fileType}/${taskPkId}`,
    method: 'get',
    responseType: 'blob'
  })
}
export function download(pkId) {
  return request({
    url: '/api/script/convert/task/download/file/' + pkId,
    method: 'get',
    responseType: 'blob'
  })
}
export default {
  findListByPage,
  add,
  edit,
  del,
  upload,
  downloadFile,
  convertFile,
  download
}
